﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Basmus.Tests
{
    public static class InvokeHelper
    {
        public static void Invoke<TTest>(this TTest test, string methodName, Type elementType)
        {
                typeof (TTest)
                    .GetMethod(methodName)
                    .MakeGenericMethod(elementType)
                    .Invoke(test, null);
        }

        public static void InvokeMany<TTest>(this TTest test, string methodName, IEnumerable<Type> elementTypes)
        {
            foreach (var elementType in elementTypes)
            {
                Invoke(test, methodName, elementType);
            }
        }

        public static void Invoke<TTest>(this TTest test, string methodName, params Type[] elementTypes)
        {
            typeof(TTest)
                .GetMethod(methodName)
                .MakeGenericMethod(elementTypes)
                .Invoke(test, null);
        }
    }
}
